-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: [ts-starter #6] implement theming infrastructure #10
base: main
Are you sure you want to change the base?
Conversation
src/pages/test.tsx
Outdated
</option> | ||
))} | ||
</select> | ||
<Typography> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- That's a weird name and highly confusing given that antd it'self has a component named like that. Name it TypographySample instead.
...defaultTheme, | ||
colorText: "#ffffff", | ||
colorBgContainer: "#000000", | ||
colorBgElevated: "#333333", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd think that all but colorWhite also need adapting here i. e. also colorTextPrimary
and colorTextSecondary
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return ( | ||
<ThemeContext.Provider | ||
value={{ | ||
selectTheme, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- memoize value
Passing value unmemoized is a horrible thing to do. Every component that makes use of the theme object will be rerendered everytime App.tsx is rerendered because of this. value absolutely must be memoized for that not to happen! You need to know where not memoizing things will cascade down and cause a lot of unnecessary rerenders. Contexts, especially those high up the react tree are one of those candidates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The selectTheme function has been created using useCallback. I thought that should be enough to prevent the reference from changing.
}; | ||
|
||
useEffect(() => { | ||
selectTheme(getStoredTheme()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why do you use useEffect here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to apply the loaded theme from the local storage and It's supposed to run just once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the code
No description provided.